package com.example.onlinemusic.service;

import com.example.onlinemusic.mapper.LoveMusicMapper;
import com.example.onlinemusic.mapper.MusicMapper;
import com.example.onlinemusic.model.Music;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LoveMusicService {

    @Autowired
    private LoveMusicMapper loveMusicMapper;
    //    查询喜欢的音乐
    public Music findLoveMusicByMusicIdAndUserId(int userId, int musicId){
        return loveMusicMapper.findLoveMusicByMusicIdAndUserId(userId,musicId);
    }
    //收藏音乐
    public boolean insertLoveMusic(int userId,int musicId){
        return loveMusicMapper.insertLoveMusic(userId,musicId);
    }

    public List<Music> findLoveMusicByUserId(int userId){
        return  loveMusicMapper.findLoveMusicByUserId(userId);
    }
    //    查询当前用户，指定为musicName的音乐，支持模糊查询
    public List<Music> findLoveMusicBykeyAndUID(String musicName,int userId){
        return loveMusicMapper.findLoveMusicBykeyAndUID(musicName,userId);
    }

    public int deleteLoveMusic(int userId,int musicId){
        return loveMusicMapper.deleteLoveMusic(userId, musicId);
    }

}
